package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonPage;
import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.ScoreSign;
import com.ytjj.qmyx.admin.model.request.ScoreSignRequest;
import com.ytjj.qmyx.admin.service.ScoreSignService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 积分签到
 */
@RestController
@RequestMapping("/scoreSign")
public class ScoreSignController {

    @Resource
    private ScoreSignService scoreSignService;

    @PostMapping("/list")
    public CommonResult list(@RequestBody ScoreSignRequest request){
        CommonPage<ScoreSign> list = scoreSignService.selectList(request);
        return CommonResult.success(list);
    }

    @PostMapping("/updateScoreSign")
    @OperLog(operModule = "积分签到模块", operDesc = "修改积分签到", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult update(@RequestBody ScoreSignRequest request){
        int count = scoreSignService.updateScoreSign(request);
        if (count > 0) {
            return CommonResult.success(count);
        }
        return CommonResult.failed();
    }
}
